import request from '@/utils/request'
import type { ApiResult, BaseIds, PageSchema } from '@/api/api'
import type {
  Post,
  PostAddDTO,
  PostModDTO,
  PostQueryDTO,
} from '@/api/system/post/type'

const BASE_URL = '/admin/api/v1/system/post'
const API = {
  BASE_URL,
  PAGE_URL: BASE_URL + '/page',
  LIST_URL: BASE_URL + '/list',
  REMOVE_URL: BASE_URL + '/rm',
}
// 添加职位信息
export const postAdd = (data: PostAddDTO) => {
  return request.post<any, ApiResult<unknown>>(API.BASE_URL, data)
}
// 修改职位信息
export const postMod = (data: PostModDTO) => {
  return request.put<any, ApiResult<unknown>>(API.BASE_URL, data)
}
// 删除职位信息
export const postDel = (data: BaseIds) => {
  return request.post<any, ApiResult<unknown>>(API.REMOVE_URL, data)
}
// 查询职位信息
export const postList = (data: PostQueryDTO) => {
  return request.post<any, ApiResult<Post[]>>(API.LIST_URL, data)
}
// 查询分页数据
export const postQuery = (data: PostQueryDTO) => {
  return request.post<any, ApiResult<PageSchema<Post>>>(API.PAGE_URL, data)
}
